package com.liming.user.controller;

import com.liming.common.pojo.vo.product.CategoryTreeVO;
import com.liming.common.pojo.vo.product.CategoryVO;
import com.liming.common.result.LMResult;
import com.liming.product.client.CategoryClient;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author liming
 * @date 2025/3/20
 */
@Slf4j
@RestController
@AllArgsConstructor
@Tag(name = "分类接口-Web")
@RequestMapping("/user/category")
public class CategoryController {

    private final CategoryClient categoryClient;

    @Operation(
            summary = "列表 - 精选分类",
            responses = {
                    @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "1", description = "获取成功", content = {
                            @Content(mediaType = "application/json", schema = @Schema(implementation = CategoryVO.class))
                    })
            }
    )
    @GetMapping("selected")
    public LMResult<List<CategoryVO>> selected() {
        return LMResult.success(categoryClient.selectedCategory());
    }

    @Operation(
            summary = "分类树",
            responses = {
                    @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "1", description = "获取成功", content = {
                            @Content(mediaType = "application/json", schema = @Schema(implementation = CategoryTreeVO.class))
                    })
            }
    )
    @GetMapping("tree")
    public LMResult<List<CategoryTreeVO>> tree() {
        return LMResult.success(categoryClient.tree());
    }

}
